﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XrmLibrary.MsCrm4Adapter.Extensions
{
    public static class ValidationResultExtensions
    {
        public static Microsoft.Crm.Sdk.Messages.ValidationResult ToCrm2011ValidationResult(this Microsoft.Crm.Sdk.ValidationResult crm4ValidationResult)
        {
            return new Microsoft.Crm.Sdk.Messages.ValidationResult
            {
                ActivityId = crm4ValidationResult.ActivityId,
                TraceInfo = crm4ValidationResult.TraceInfo.ToCrm2011TraceInfo(),
                ValidationSuccess = crm4ValidationResult.ValidationSuccess
            };
        }

        public static IEnumerable<Microsoft.Crm.Sdk.Messages.ValidationResult> ToCrm2011ValidationResultCollection(this Microsoft.Crm.Sdk.ValidationResult[] crm4ValidationResult)
        {
            foreach (Microsoft.Crm.Sdk.ValidationResult validationResult in crm4ValidationResult)
            {
                yield return validationResult.ToCrm2011ValidationResult();
            }
        }
    }
}
